package com.cheyun.netsalev3.view

import android.content.Intent
import android.text.Editable
import android.text.InputType
import android.text.TextWatcher
import android.view.View
import android.widget.TextView
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProviders
import androidx.recyclerview.widget.RecyclerView
import com.cheyun.netsalev3.R
import com.cheyun.netsalev3.adapter.MyAdapter
import com.cheyun.netsalev3.databinding.ActivityBindDistributorBinding
import com.cheyun.netsalev3.databinding.ActivityForgetBinding
import com.cheyun.netsalev3.databinding.ActivityRegisterBinding
import com.cheyun.netsalev3.utils.BaseActivity
import com.cheyun.netsalev3.viewmodel.BindDistributorActivityViewModel
import com.cheyun.netsalev3.viewmodel.ForgetActivityViewModel
import com.cheyun.netsalev3.viewmodel.RegisterActivityViewModel

class BindDistributorActivity : BaseActivity<ActivityBindDistributorBinding>() {
    override fun initContentView(): Int {
        return R.layout.activity_bind_distributor
    }
    override fun initViewModel(): ViewModel? {
        return ViewModelProviders.of(this).get(BindDistributorActivityViewModel::class.java)
    }
    private lateinit var adapter: MyAdapter

    override fun initData() {
        binding.viewModel?.channellist?.observe(this, Observer { list ->
            adapter.submitList(list)
        })
    }


    override fun initView() {
        binding.viewModel?.activity = this
        var single = intent.getBooleanExtra("single",false)
        if(single){
            binding.headview.findViewById<TextView>(R.id.leftBut).visibility = View.GONE
            binding.viewModel?.single = single
            binding.headview.findViewById<TextView>(R.id.rightBut).visibility = View.VISIBLE

            binding.headview.rightBut?.setOnClickListener {
                binding.viewModel?.longOut()
            }
        }else{
            binding.headview.findViewById<TextView>(R.id.rightBut).visibility = View.GONE
        }

        adapter = MyAdapter(R.layout.dealers_apply_item, binding.viewModel)
        var recyclerView = binding.root.findViewById<RecyclerView>(R.id.swipe_target)
        recyclerView.adapter = adapter

    }
}
